package Actions;

import java.awt.Button;
import java.awt.Dialog;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.Label;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;


public class HelpDialog {
	private TypeWriter.TypeWriter parent;
	private Dialog d;
	
	public HelpDialog(TypeWriter.TypeWriter parent)
	{
		this.parent = parent;
		
		// Create a modal dialog
		d = new Dialog(this.parent, "Help", true);

		// Use a flow layout
		d.setLayout( new GridLayout(5,2) );
		

		// Create an OK button
		Button ok = new Button ("OK");
		ok.addActionListener ( new ActionListener()
		{
			public void actionPerformed( ActionEvent e )
			{
				// Hide dialog
				HelpDialog.this.d.setVisible(false);
			}
		});
		
		
		d.add( new Label("Ctl+k = Options Dialog") );
		d.add( new Label("Ctl+n = New file") );
		d.add( new Label("Ctl+o = Open file") );
		d.add( new Label("Ctl+s = Save file") );
		d.add( new Label("Ctl+Alt+s = Save file as") );
		d.add( new Label("Ctl+f = Choose fourground") );
		d.add( new Label("Ctl+b = Choose background") );
		d.add( new Label("Ctl+t = Choose font") );
		d.add( new Label("Esc = Toggle fullscreen") );
		
		d.add( ok );

		// Show dialog
		d.pack();
		
		// size position
		Dimension size = Toolkit.getDefaultToolkit().getScreenSize();
		d.setLocation(size.width/2 - d.getWidth(), size.height/2 - d.getHeight());
	}
	
	public void show()
	{
		d.setVisible(true);
	}
	
	public void disposeDialog()
	{
		d.dispose();
	}
	
}
